#ifndef __Channel_HPP__
#define __Channel_HPP__
#include <iostream>
using namespace std;
#include <string>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <cstdlib>
#include <vector>
#include <functional>
#include "Task.hpp"

class Channel
{
public:
    Channel(int wfd, pid_t who) : _wfd(wfd), _who(who)
    {
        _name = "Channel-" + std::to_string(wfd) + "-" + to_string(who);
    }

    string Name()
    {
        return _name;
    }

    void Send(int cmd)
    {
        ::write(_wfd, &cmd, sizeof(cmd));
    }
    void Close()
    {
        ::close(_wfd);
    }
    pid_t Id()
    {
        return _who;
    }
    int wfd()
    {
        return _wfd;
    }
    ~Channel()
    {
    }

private:
    int _wfd;
    string _name;
    pid_t _who;
};

#endif